package com.dyit.springcloud.hospital.web.controller;


import com.dyit.springcloud.hospital.common.dto.HttpResp;
import com.dyit.springcloud.hospital.web.util.Code;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.time.LocalDateTime;

@RestController
@RequestMapping("/api/web")
public class CodeController {

    @GetMapping("/code.png")
    public HttpResp makeCode(HttpServletResponse response, HttpSession session)throws Exception{
        int code = Code.create(response.getOutputStream());
        session.setAttribute("code",code);
        return new HttpResp(2001,"验证码制作完成", LocalDateTime.now());
    }

    public HttpResp login(){

        return null;
    }
}
